package lt.bcra.handler;


import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 生成问卷编号
 */

@Data
@NoArgsConstructor
public class QuestionnaireCode {

    //对应的手机号取后四位 一共11位
    private String phone;
    //取时间戳后取后四位 一共13位
    private String timeStamp;
    //前缀
    private String prefix;
    //最终的问卷编码
    private StringBuilder resultCode;

    /**
     * 问卷编号生成
     *
     * @param totalPhone
     */
    public QuestionnaireCode(String totalPhone) {

        String phone = totalPhone.substring(7);
        this.phone = phone;

        String totalTime = String.valueOf(System.currentTimeMillis());
        String timeStamp = totalTime.substring(9);
        this.timeStamp = timeStamp;

        this.prefix = "LT";

        StringBuilder stringBuilder = new StringBuilder();

        this.resultCode=stringBuilder.append("LT").append("-").append(phone).append("-").append(timeStamp);
    }
}
